Skip to content

chore: add conventional commits pre-commit hook#85

Merged
sanafayyaz315 merged 2 commits into
red-hat-data-services:mainfrom
sanafayyaz315:pre-commit-hooks-clean
May 4, 2026
Merged

chore: add conventional commits pre-commit hook#85
sanafayyaz315 merged 2 commits into
red-hat-data-services:mainfrom
sanafayyaz315:pre-commit-hooks-clean

Conversation

@sanafayyaz315
Copy link
Copy Markdown
Contributor

Description

Adds a pre-commit hook to enforce the Conventional Commits specification on all commit messages. Uses the espressif/conventional-precommit-linter hook, which validates commit message format at the commit-msg stage.

Changes:

  • .pre-commit-config.yaml: new file with the conventional commits hook configured with allowed types, subject length limits, and breaking change support
  • CONTRIBUTING.md: added "Development setup" section with pre-commit install instructions and updated "Commit message conventions" with the enforced format, all allowed types, and examples

Jira Ticket

RHAIENG-4066

Testing

  • make test passes (run from the affected agent directory)
  • Manual testing performed (describe steps below)
  • No testing required (documentation/config change only)

Verified locally:

  • Bad commit messages (e.g. "updated stuff", "chore: doc") are rejected
  • Valid commit messages (e.g. "chore: add conventional commits pre-commit hook") pass

Checklist

  • I have read CONTRIBUTING.md
  • No .env or secret files are included in this PR
  • All changes are within scope of the linked Jira ticket

Review Guidance

Review Guidance

  • .pre-commit-config.yaml — review the args to confirm the team is happy with the allowed types and subject length limits (min 10, max 72)
  • Additional args available from the linter that we're not currently using:
    • --scopes: restrict to specific scopes (currently unrestricted)
    • --body-max-line-length: limit body line length (currently unrestricted)
    • --summary-uppercase: enforce uppercase first letter
    • --scope-case-insensitive: allow uppercase in scopes
  • This is phase 1 of pre-commit setup. Ruff, markdownlint, and file-hygiene hooks will be added in a follow-up PR once the linter configs (ruff.toml, .markdownlint.json) are in place.

Related PRs

#80 (Tarun's Ruff linting and formatting — provides ruff.toml that future pre-commit hooks will use)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

The pull request introduces a pre-commit hook configuration that enforces Conventional Commits in the repository, paired with updated contribution guidelines that document the new development setup and commit message format requirements.

Changes

Cohort / File(s) Summary
Pre-commit Configuration
.pre-commit-config.yaml
New configuration file that registers conventional-precommit-linter v1.11.0 at the commit-msg stage to validate commit messages against Conventional Commits specification with enforced subject length bounds (10–72 characters) and support for breaking changes.
Documentation Updates
CONTRIBUTING.md
Added "Development setup" section requiring pre-commit hook installation; replaced commit-prefix guidance with formal Conventional Commits format template and expanded "Allowed types" table; updated examples to include breaking change syntax (! and BREAKING CHANGE: footer).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a conventional commits pre-commit hook configuration.
Description check ✅ Passed The description is well-structured and directly related to the changeset, providing context, implementation details, testing evidence, and reviewer guidance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread .pre-commit-config.yaml
Comment thread CONTRIBUTING.md Outdated
Comment thread CONTRIBUTING.md Outdated
Comment thread CONTRIBUTING.md Outdated
@sanafayyaz315 sanafayyaz315 force-pushed the pre-commit-hooks-clean branch from ccfbf3d to d85856d Compare April 30, 2026 08:01
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
CONTRIBUTING.md (1)

45-97: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix MD040: add language tags to fenced code blocks.

Static analysis flags MD040 because the fenced code blocks at:

  • Line 51 (Format template)
  • Line 92 (BREAKING CHANGE example)
    don’t specify a language. This is a quick doc maintainability fix and prevents future markdownlint failures.
💡 Proposed change
-```
+```text
 <type>(optional scope): <description>
 
 [optional body]
 
 [optional footer(s)]

...

- +text
feat: change /chat response format

BREAKING CHANGE: response field "text" renamed to "content"

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CONTRIBUTING.md` around lines 45 - 97, Add language tags to the two fenced
code blocks that triggered MD040: the commit message format block containing
"<type>(optional scope): <description> ... [optional footer(s)]" and the
BREAKING CHANGE example block beginning with "feat: change /chat response
format" so both fences use a language tag (e.g., ```text) to satisfy
markdownlint; update those two fences accordingly.
🧹 Nitpick comments (1)
.pre-commit-config.yaml (1)

1-23: ⚡ Quick win

Consider merge-commit handling (and verify linter CLI flag support).

With conventional-precommit-linter running at commit-msg and no merge-skip/exception config, local merges may be rejected due to default merge messages (e.g., Merge branch ... into ...). You already document git commit --no-verify in CONTRIBUTING.md, but it may not apply cleanly to all commit-creating commands (merge/cherry-pick/rebase), and the linter may also have a “skip merge commits” option.

Please verify:

  1. Whether this linter supports an option to skip merge commits (or treat them as exempt), and
  2. That the provided --types=..., --subject-min-length, --subject-max-length, and --allow-breaking flags match the linter’s expected CLI syntax for v1.11.0.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.pre-commit-config.yaml around lines 1 - 23, The commit-msg hook
configuration for the conventional-precommit-linter (hook id:
conventional-precommit-linter) may reject merge commits and/or be using
incorrect CLI flags; verify whether v1.11.0 supports a "skip merge commits" or
equivalent flag (or an allow/ignore pattern) and confirm the exact flag
names/syntax for --types, --subject-min-length, --subject-max-length and
--allow-breaking; if the linter supports skipping merges, update the hook args
to include that flag (or add an explicit exempt pattern for merge commit
messages), otherwise adjust the configuration to a supported flag syntax or add
documentation instructing use of --no-verify for automated merges and rebases so
that merge/cherry-pick/rebase workflows aren’t blocked (refer to the hook id
conventional-precommit-linter and the current args list to locate where to
change).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@CONTRIBUTING.md`:
- Around line 45-97: Add language tags to the two fenced code blocks that
triggered MD040: the commit message format block containing "<type>(optional
scope): <description> ... [optional footer(s)]" and the BREAKING CHANGE example
block beginning with "feat: change /chat response format" so both fences use a
language tag (e.g., ```text) to satisfy markdownlint; update those two fences
accordingly.

---

Nitpick comments:
In @.pre-commit-config.yaml:
- Around line 1-23: The commit-msg hook configuration for the
conventional-precommit-linter (hook id: conventional-precommit-linter) may
reject merge commits and/or be using incorrect CLI flags; verify whether v1.11.0
supports a "skip merge commits" or equivalent flag (or an allow/ignore pattern)
and confirm the exact flag names/syntax for --types, --subject-min-length,
--subject-max-length and --allow-breaking; if the linter supports skipping
merges, update the hook args to include that flag (or add an explicit exempt
pattern for merge commit messages), otherwise adjust the configuration to a
supported flag syntax or add documentation instructing use of --no-verify for
automated merges and rebases so that merge/cherry-pick/rebase workflows aren’t
blocked (refer to the hook id conventional-precommit-linter and the current args
list to locate where to change).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: e3eac864-3611-4424-8119-f50e6c0a67bb

📥 Commits

Reviewing files that changed from the base of the PR and between 07331fe and d85856d.

📒 Files selected for processing (2)
  • .pre-commit-config.yaml
  • CONTRIBUTING.md

@mpk-droid
Copy link
Copy Markdown
Contributor

LGTM

Copy link
Copy Markdown
Contributor

@mpk-droid mpk-droid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sanafayyaz315 sanafayyaz315 merged commit 4e83dbf into red-hat-data-services:main May 4, 2026
3 checks passed
sanafayyaz315 added a commit to sanafayyaz315/agentic-starter-kits that referenced this pull request May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants